import { Contract } from "@ethersproject/contracts";

import ERC20_ABI from "../constants/abis/erc20.json";


import { getContractMulticall  } from "./utils.js";


// returns null on errors
function useContract(
  address,
  ABI,

) {
  // console.log('useContract');
  if (!address || !ABI) return null;
  try {
    // return new web3.eth.Contract(ABI,address)
    return getContractMulticall(
      address,
      ABI
    );
  } catch (error) {
    console.error("Failed to get contract", error);
    return null;
  }
}

export function useTokenContractMulticall(
  token
) {
  // console.info("- -useTokenContract");
  return useContract(
    token.address,
    ERC20_ABI
  );
}
